<template>
  <div class="newsInfo_box">
    <h3>{{ newsInfo.title }}</h3>
    <p class="top_p">
      <span>发表时间：{{ newsInfo.add_time | data}}</span>
      <span>点击次数：{{ newsInfo.click }}</span>
    </p>
    <hr>
    <div class="content" v-html="newsInfo.content"></div>
    <comment :id="this.id"></comment>
  </div>
</template>
<script>
import { Toast } from "mint-ui";
import comment from "../subcomponents/comment.vue";
export default {
  data() {
    return {
      id: this.$route.params.id,
      newsInfo: []
    };
  },
  components: {
    comment
  },
  created() {
    this.getNewsInfoList();
  },
  methods: {
    getNewsInfoList() {
      this.$http.get("api/getnew/" + this.id).then(res => {
        if (res.body.status === 0) {
          this.newsInfo = res.body.message[0];
        } else {
          Toast("获取失败");
        }
      });
    }
  }
};
</script>
<style lang="less">
.newsInfo_box {
  padding: 4px;
  h3 {
    font-size: 16px;
    text-align: center;
    color: red;
  }
  .top_p {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    color: #226aff;
  }
}
</style>